Integrate Application Insights and OpenTelemetry for CLI observability#1838
Conversation
|
Since the CLI is a public package available to anyone, any tracking mechanism must be opt-in and accompanied by a privacy policy. The same applies to pipelines. Alternatively, we must restrict tracking to internal usage only |
3164682 to
bffee13
Compare
restricted to pagopa users only, via github |
bffee13 to
85a4b82
Compare
ecff58e to
0d4b05f
Compare
0d4b05f to
fa45050
Compare
03201bb to
80b449d
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds end-to-end observability for the dx CLI by integrating Azure Monitor (Application Insights) and OpenTelemetry, including a single root span for each CLI invocation and log export via Logtape → OTel. It also tightens CLI preconditions (GitHub auth) and updates workspace dependency catalogs/lockfiles accordingly.
Changes:
- Add Azure Monitor/OpenTelemetry preload + runtime enablement, root span tracing, and OTel log sink wiring for the CLI.
- Enforce GitHub authentication for all CLI commands except
--help/--version, with telemetry enabled only forpagopaorg members. - Update dependency catalogs/lockfile and documentation to reflect new auth + telemetry behavior.
Reviewed changes
Copilot reviewed 15 out of 17 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-workspace.yaml | Adds/updates OpenTelemetry-related catalog entries and normalizes quoting/format. |
| pnpm-lock.yaml | Updates lockfile to include new OTel/Logtape/Azure Monitor dependencies and related transitive changes. |
| package.json | Updates packageManager and adds pnpm overrides at root. |
| apps/website/docs/dx-cli/requirements.md | Documents mandatory GitHub auth and telemetry enablement rules. |
| apps/cli/src/index.ts | Adds early auth/telemetry gating, OTel log sink, root span lifecycle, and tool-version enrichment. |
| apps/cli/src/adapters/plop/actions/setup-pnpm.ts | Strips debugger-related env vars from spawned processes. |
| apps/cli/src/adapters/octokit/index.ts | Adds isPagopaOrgMember helper to gate telemetry. |
| apps/cli/src/adapters/octokit/tests/index.test.ts | Adds unit tests for isPagopaOrgMember. |
| apps/cli/src/adapters/commander/commands/doctor.ts | Avoids process.exit() to allow telemetry flush in finally. |
| apps/cli/src/adapters/commander/commands/add.ts | Extends action result shape to include the environment payload. |
| apps/cli/src/adapters/azure-monitor/telemetry.ts | Adds flushTelemetry() helper to shutdown/flush Azure Monitor SDK safely. |
| apps/cli/src/adapters/azure-monitor/instrumentation.ts | Adds preload module hook registration + Azure Monitor enablement and resource attribute setup. |
| apps/cli/README.md | Documents GitHub auth requirement and telemetry scope. |
| apps/cli/package.json | Adds Azure Monitor + OTel deps and Logtape OTel sink deps to the CLI app. |
| apps/cli/bin/index.js | Ensures instrumentation preload is imported before the CLI entrypoint via sequential dynamic imports. |
| .nx/version-plans/version-plan-1781270390103.md | Version plan for docs change (GitHub login requirement). |
| .nx/version-plans/version-plan-1781270291055.md | Version plan for CLI telemetry behavior change. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
94ef95f to
6f50e56
Compare
6f50e56 to
1ab8c3b
Compare
1ab8c3b to
16ac30e
Compare
16ac30e to
b1cfcc6
Compare
b1cfcc6 to
c2de757
Compare
c2de757 to
ce583b9
Compare
ce583b9 to
91213a8
Compare
91213a8 to
4b7d615
Compare
7ae754a to
03f40ac
Compare
03f40ac to
aa73aec
Compare
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://proud-mud-0405c6703-1838.westeurope.1.azurestaticapps.net |



Implement OpenTelemetry logging for improved observability, including root span tracing for CLI commands. Enhance telemetry capabilities by concurrently fetching tool versions and adding Azure Monitor service name.